CXX = g++
CXXFLAGS = -std=c++17 -Wall -I../thirdLib/proto -I../thirdLib/net -I../thirdLib/base -I../mqCommon

LDFLAGS = -L/path/to/muduo/lib -lmuduo_net -lmuduo_base -lprotobuf -lsqlite3 -lpthread -lz

PROTO_SRCS = ../mqCommon/mq_msg.pb.cc ../mqCommon/mq_proto.pb.cc
PROTO_HDRS = ../mqCommon/mq_msg.pb.h ../mqCommon/mq_proto.pb.h
CODEC_SRC = ../thirdLib/proto/codec.cc

# 如果将来还加 base 里的 cpp，只需要写上 ../thirdLib/base/xxx.cpp
SERVER_SRCS = mq_server.cpp $(PROTO_SRCS) $(CODEC_SRC)
SERVER_OBJS = $(SERVER_SRCS:.cpp=.o)
SERVER_OBJS := $(SERVER_OBJS:.cc=.o)
SERVER_EXE = server

.PHONY: all clean

all: $(SERVER_EXE)

$(SERVER_EXE): $(SERVER_OBJS)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

%.o: %.cpp $(PROTO_HDRS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

%.o: %.cc $(PROTO_HDRS)
	$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
	rm -f $(SERVER_OBJS) $(SERVER_EXE)
